import request from '@/utils/request'
import qs from 'qs'

const prefix = '/v1'

export function userList(params) {
    return request.get(`${prefix}/user/list`, {params}) 
}

export function saveOrUpdate(params) {
    return request.post(`${prefix}/employee/saveOrUpdate`, params)
}

// 用户中重置密码
export function restPassword(params) {
    return request.post(`${prefix}/user/restPassword`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

// 从 token 中获取用户信息
export function getLoginInfo(params) {
    return request.post(`${prefix}/user/getLoginInfo`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

export function deleteById(params) {
    return request.post(`${prefix}/user/delete`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

export function changeStatus(params) {
    return request.post(`${prefix}/user/changeStatus`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}

export function register(params) {
    return request.post(`${prefix}/user/register`, params)
    
}

export function checkUsernameExist(params) {
    return request.post(`${prefix}/user/checkUsernameExist`, qs.stringify(params, {
        method: 'POST',
        headers: {'content-type': 'application/x-www-form-urlencoded'}
    }));
}